from django.shortcuts import render
from django.http import HttpResponse
from django import forms
from User import models
from django.core.validators import RegexValidator
from django_redis import get_redis_connection


# 注册页面视图函数
from web.forms.account import ResigterModel


def register_view(request):
    form = ResigterModel()
    if request.method == 'GET':
        return render(request, 'User/register.html', {'form': form})
    elif request.method == 'POST':
        uname = request.POST.get('uname')
        pwd = request.POST.get('upwd')
        email = request.POST.get('uemail')
        phone = request.POST.get('uphone')
        return render(request, 'User/login.html', locals())
    else:
        return HttpResponse('请求错误！')


def test_redis(request):
    conn = get_redis_connection()#默认default
    conn.set('name', 'sxj', ex=60)
    print(conn.get('name'))
    return HttpResponse('OK')
